package com.alageek.study.handler;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice
public class CustomExceptionHandler {
    @ExceptionHandler(MaxUploadSizeExceededException.class)
    public ModelAndView uploadException(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg", "上传文件大小超出限制！");
        modelAndView.setViewName("error");
        return modelAndView;
    }
}
